﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KNXFramework.KNXObjects.ValueObjects.Signed
{
    internal class IntObjectValue : IValueObject
    {
        protected int m_Value;

        #region Constructors

        public IntObjectValue()
        {

        }
        public IntObjectValue(string value)
        {
            if (!int.TryParse(value, out m_Value))
                throw new ApplicationException(string.Format("Format error, cannot convert value {0} to INT32", value)); 
        }
        public IntObjectValue(int value)
        {
            m_Value = value;
        }

        #endregion
        #region IValueObject Members

        public virtual void AdaptBufferBeforeSending(bool isWrite, tuwien.auto.eibclient.EIBBuffer buffer)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IEquatable<IValueObject> Members

        public bool Equals(IValueObject other)
        {
            IntObjectValue otherVal = other as IntObjectValue;
            bool equality = false;
            if (otherVal != null)
                equality = m_Value.Equals(otherVal.m_Value);

            return equality;
        }

        #endregion

        public override string ToString()
        {
            return m_Value.ToString();
        }
    }
}
